package com.ruirenyun.config.elasticsearch;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;

/**
 * @Author huangpeng
 * @Title es配置类
 * @Package
 * @Date 2021/5/7 10:39
 * @Description
 * @Version 1.0
 */
@Configuration
public class ElasticsearchConfig {
    @Bean
    RestHighLevelClient elasticsearchClient(){
        ClientConfiguration configuration = ClientConfiguration.builder()
                .connectedTo("192.168.137.224:19004")
                //.withConnectTimeout(Duration.ofSeconds(5))
                //.withSocketTimeout(Duration.ofSeconds(3))
                //.useSsl()
                //.withDefaultHeaders(defaultHeaders)
                //.withBasicAuth(username, password)
                // ... other options
                .build();
        RestHighLevelClient client = RestClients.create(configuration).rest();

        return client;
    }
}
